lets_plot.theme¶
-
lets_plot.theme(*, axis_title=None, axis_title_x=None, axis_title_y=None, axis_text=None, axis_text_x=None, axis_text_y=None, axis_ticks=None, axis_ticks_x=None, axis_ticks_y=None, axis_line=None, axis_line_x=None, axis_line_y=None, legend_position=None, legend_justification=None, legend_direction=None, axis_tooltip=None, axis_tooltip_x=None, axis_tooltip_y=None, **kwargs)¶ Use theme() to modify individual components of a theme, allowing you to control the appearance of all non-data components of the plot.
- Parameters
axis_title (str or FeatureSpec) – Label of axes. Set ‘blank’ or result of element_blank() to draw nothing and assign no space.
axis_title_x (str or FeatureSpec) – x axis label. Set ‘blank’ or result of element_blank() to draw nothing and assign no space.
axis_title_y (str or FeatureSpec) – y axis label. Set ‘blank’ or result of element_blank() to draw nothing and assign no space.
axis_text (str or FeatureSpec) – Tick labels along axes. Set ‘blank’ or result of element_blank() to draw nothing and assign no space.
axis_text_x (str or FeatureSpec) – x axis tick labels. Set ‘blank’ or result of element_blank() to draw nothing and assign no space.
axis_text_y (str or FeatureSpec) – y axis tick labels. Set ‘blank’ or result of element_blank() to draw nothing and assign no space.
axis_ticks (str or FeatureSpec) – Tick marks along axes. Set ‘blank’ or result of element_blank() to draw nothing and assign no space.
axis_ticks_x (str or FeatureSpec) – x axis tick marks. Set ‘blank’ or result of element_blank() to draw nothing and assign no space.
axis_ticks_y (str or FeatureSpec) – y axis tick marks. Set ‘blank’ or result of element_blank() to draw nothing and assign no space.
axis_line (str or FeatureSpec) – Lines along axes. Set ‘blank’ or result of element_blank() to draw nothing and assign no space.
axis_line_x (str or FeatureSpec) – Line along x axis. Set ‘blank’ or result of element_blank() to draw nothing and assign no space.
axis_line_y (str or FeatureSpec) – Line along y axis. Set ‘blank’ or result of element_blank() to draw nothing and assign no space.
legend_position ({‘none’, ‘left’, ‘right’, ‘bottom’, ‘top’} or list) – The position of legends. To remove the plot legend, use the ‘none’ value. If parameter is a list, then it should be a two-element numeric vector, each value of float type between 0 and 1.
legend_justification (str or list) – Anchor point for positioning legend. If parameter is a list, then it should be a two-element numeric vector. The pair [0, 0] corresponds to the bottom left corner, the pair [1, 1] corresponds to the top right. For string parameter the only possible value is ‘center’.
legend_direction ({‘horizontal’, ‘vertical’}) – Layout of items in legends.
axis_tooltip (str or FeatureSpec) – Axes tooltips. Set ‘blank’ or result of element_blank() to draw nothing and assign no space.
axis_tooltip_x (str or FeatureSpec) – x axis tooltips. Set ‘blank’ or result of element_blank() to draw nothing and assign no space.
axis_tooltip_y (str or FeatureSpec) – y axis tooltips. Set ‘blank’ or result of element_blank() to draw nothing and assign no space.
- Returns
Theme specification.
- Return type
FeatureSpec
Examples
1 2 3 4 5 6 7 8 9 10 11 12 13
import numpy as np from lets_plot import * LetsPlot.setup_html() cats = ['a', 'b', 'c', 'd', 'e'] np.random.seed(42) p = np.random.uniform(size=len(cats)) x = np.random.choice(cats, p=p/p.sum(), size=1000) ggplot({'x': x}, aes(x='x')) + \ geom_bar(aes(fill='x')) + \ scale_fill_discrete(name='cat') + \ theme(axis_title_x='blank', axis_text_x='blank', \ axis_ticks_x='blank', axis_line='blank', \ legend_position='bottom')
1 2 3 4 5 6 7 8 9 10 11 12 13
import numpy as np from lets_plot import * LetsPlot.setup_html() n = 100 np.random.seed(42) x = np.random.normal(size=n) y = np.random.normal(size=n) v = np.random.uniform(size=n) ggplot({'x': x, 'y': y, 'v': v}, aes('x', 'y')) + \ geom_point(aes(color='v')) + \ scale_color_gradient(name='value') + \ theme(axis_tooltip=element_blank(), legend_direction='horizontal', \ legend_position=[1, 1], legend_justification=[1, 1])